const app = getApp();
var utils = require('../../utils/util.js');
Component({
  properties: {
    downLoadUrl: {
      type: String,
      value: app.getApi('download')
    },
    indicatorDots: {
      type: Boolean,
      value: true
    },
    appid: {
      type: String,
      value: "wx8407e4c0b132614a" //拼量商城
    },
    indicatorActiveColor: {
      type: String,
      value: "rgba(255,102,51,1)"
    },
    autoplay: {
      type: Boolean,
      value: true,
    },
    interval: {
      type: Number,
      value: 3000
    },
    duration: {
      type: Number,
      value: 500
    },
    circular: {
      type: Boolean,
      value: true
    },
    height: {//宽高
      type: Number,
      value: 375
    },
    width: {
      type: Number,
      value: 750
    },
    radius: {//圆角大小
      type: String,
      value: '0rpx'
    },
    prev: {//前边距，可用于露出前一项的一小部分，
      type: String,
      value: 0
    },
    next: {//后边距，可用于露出后一项的一小部分，
      type: String,
      value: 0
    },
    prevornext: {//同时设置一样的 前边距与后边距
      type: String,
      value: 0
    },
    shadow:{
      type: Boolean,
      value: false
    },
    imgs: {
      type: Array,
      value:[]
    }
  },
  data: {
    swiperIndex:0
  },
  methods: {
    setswiperIndex(){
      this.setData({
        swiperIndex: 0
      })
    },
    bindchange(e) {
      if (e.detail.current == this.data.swiperIndex){
        return;
      }
      this.setData({
        swiperIndex: e.detail.current
      })
    },
    itemTap(e) {
      var {
        item,
        currentindex
      } = e.currentTarget.dataset;
      this.setData({
        swiperIndex: currentindex
      },()=>{
        if (item.linkType==4){
          return;
        }
        item.link && item.link != '/' && utils.toPage(item.link)
      })
    },
    // swiperTap(e) {
    //   var { currentindex } = e.currentTarget.dataset
    //   this.setData({
    //     swiperIndex: currentindex
    //   })
    // },
  }
})